package com.gmrz.webauthn.protocol.v1.schema;

import com.gmrz.uaf.common.Constants;
import com.gmrz.uaf.protocol.v1.schema.AAID;
import com.gmrz.uaf.protocol.v1.schema.Extension;
import com.gmrz.uaf.protocol.v1.schema.PNGCharacteristics;
import com.gmrz.uaf.protocol.v1.schema.VerificationMethodDescriptor;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.security.cert.Certificate;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

public final class WebAuthenticatorSpec
{
    private transient long id = -1L;
    private transient String name;
    @SerializedName("aaid")
    @Expose
    private AAID aaid = null;
    @SerializedName("attestationCertificateKeyIdentifiers")
    @Expose
    private List<ACKI> attestationCertKeyIds = null;
    @SerializedName("aaguid")
    @Expose
    private String aaguid = null;
    @SerializedName("attestationRootCertificates")
    @Expose
    private List<Certificate> rootCertificates = null;
    @SerializedName("description")
    @Expose
    private String description = null;
    @SerializedName("authenticatorVersion")
    @Expose
    private Integer authenticatorVersion = Integer.valueOf(-1);
    @SerializedName("userVerificationDetails")
    @Expose
    private List<Set<VerificationMethodDescriptor>> userVerificationMethods = null;
    @SerializedName("attachmentHint")
    @Expose
    private Long validAttachmentTypes = Long.valueOf(-1L);
    @SerializedName("keyProtection")
    @Expose
    private Integer keyProtection = Integer.valueOf(-1);
    @SerializedName("matcherProtection")
    @Expose
    private Integer matcherProtection = Integer.valueOf(-1);
    @SerializedName("tcDisplay")
    @Expose
    private Integer secureDisplay = Integer.valueOf(-1);
    @SerializedName("tcDisplayContentType")
    @Expose
    private String displayContentType = null;
    @SerializedName("tcDisplayPNGCharacteristics")
    @Expose
    private List<PNGCharacteristics> displayPNGCharacteristics = null;
    @SerializedName("isSecondFactorOnly")
    @Expose
    private boolean isSecondFactorOnly = false;
    @SerializedName("icon")
    @Expose
    private String icon = null;
    @SerializedName("assertionScheme")
    @Expose
    private String assertionScheme = null;
    @SerializedName("authenticationAlgorithm")
    @Expose
    private int algorithm = -1;
    @SerializedName("publicKeyAlgAndEncoding")
    @Expose
    private int keyFormat;
    @SerializedName("attestationTypes")
    @Expose
    private List<Integer> attestationTypes;
    @SerializedName("upv")
    @Expose
    private Version[] upv = new Version[0];
//    @SerializedName("protocolFamily")
//    @Expose
//    private Constants.ProtocolFamily protocolFamily = Constants.ProtocolFamily.UAF;
//    @SerializedName("status")
//    private Constants.AuthenticatorSpecStatus status = null;
    @SerializedName("supportedExtensions")
    @Expose
    private List<Extension> supportedExtensions;
    @SerializedName("isKeyRestricted")
    @Expose
    private boolean isKeyRestricted = true;
    @SerializedName("isFreshUserVerificationRequired")
    @Expose
    private boolean isFreshUserVerificationRequired = true;
    private Timestamp createTimeStamp;
    private Timestamp updateTimeStamp;

    public List<Constants.SecureDisplay> getSecureDisplayAsList()
    {
        return Constants.SecureDisplay.forValue(this.secureDisplay.intValue());
    }

    public Integer getSecureDisplay()
    {
        return this.secureDisplay;
    }

    public void setSecureDisplay(Constants.SecureDisplay secureDisplay)
    {
        this.secureDisplay = Integer.valueOf(secureDisplay.getDisplay());
    }

    public void setSecureDisplay(int secureDisplay)
    {
        this.secureDisplay = Integer.valueOf(secureDisplay);
    }

    public List<Constants.KeyProtection> getKeyProtectionAsList()
    {
        return Constants.KeyProtection.forValue(this.keyProtection.intValue());
    }

    public Integer getKeyProtection()
    {
        return this.keyProtection;
    }

    public void setKeyProtection(int keyProtection)
    {
        this.keyProtection = Integer.valueOf(keyProtection);
    }

    public List<Constants.AttachmentHint> getAttachmentHintAsList()
    {
        return Constants.AttachmentHint.forValue(this.validAttachmentTypes.longValue());
    }

    public Long getAttachmentHint()
    {
        return this.validAttachmentTypes;
    }

    public void setAttachmentHint(long attachmentHint)
    {
        this.validAttachmentTypes = Long.valueOf(attachmentHint);
    }

    public void setAlgorithms(int algorithms)
    {
        this.algorithm = algorithms;
    }

    public int getAlgorithm()
    {
        return this.algorithm;
    }

    public void setKeyFormat(int keyFormat)
    {
        this.keyFormat = keyFormat;
    }

    public int getKeyFormat()
    {
        return this.keyFormat;
    }

    public String getDescription()
    {
        return this.description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getIcon()
    {
        return this.icon;
    }

    public void setIcon(String icon)
    {
        this.icon = icon;
    }

    public List<Certificate> getRootCertificates()
    {
        return this.rootCertificates;
    }

    public void setRootCertificates(List<Certificate> rootCertificates)
    {
        this.rootCertificates = rootCertificates;
    }

    public boolean isSecondFactorOnly()
    {
        return this.isSecondFactorOnly;
    }

    public void setSecondFactorOnly(boolean secondFactorOnly)
    {
        this.isSecondFactorOnly = secondFactorOnly;
    }

    public List<Constants.AttestationType> getAttestationTypesAsList()
    {
        List<Constants.AttestationType> at = new ArrayList();
        for (Integer i : this.attestationTypes) {
            at.add(Constants.AttestationType.forValue(i.intValue()));
        }
        return at;
    }

    public void setAttestationTypes(List<Integer> attestationTypes)
    {
        this.attestationTypes = attestationTypes;
    }

    public List<Integer> getAttestationTypes()
    {
        return this.attestationTypes;
    }

    public AAID getAAID()
    {
        return this.aaid;
    }

    public void setAAID(AAID aaid)
    {
        this.aaid = aaid;
    }

    public long getID()
    {
        return this.id;
    }

    public void setID(long id)
    {
        this.id = id;
    }

    public List<PNGCharacteristics> getDisplayPNGCharacteristics()
    {
        return this.displayPNGCharacteristics;
    }

    public void setDisplayPNGCharacteristics(List<PNGCharacteristics> displayPNGCharacteristics)
    {
        this.displayPNGCharacteristics = displayPNGCharacteristics;
    }

    public List<Set<VerificationMethodDescriptor>> getUserVerficationMethods()
    {
        return this.userVerificationMethods;
    }

    public void setUserVerficationMethods(List<Set<VerificationMethodDescriptor>> userVerificationMethods)
    {
        this.userVerificationMethods = userVerificationMethods;
    }

    public List<Constants.MatcherProtection> getMatcherProtectionAsList()
    {
        return Constants.MatcherProtection.forValue(this.matcherProtection.intValue());
    }

    public Integer getMatcherProtection()
    {
        return this.matcherProtection;
    }

    public void setMatcherProtection(Integer matcherProtection)
    {
        this.matcherProtection = matcherProtection;
    }

    public Integer getAuthenticatorVersion()
    {
        return this.authenticatorVersion;
    }

    public void setAuthenticatorVersion(Integer authenticatorVersion)
    {
        this.authenticatorVersion = authenticatorVersion;
    }

    public String getAssertionScheme()
    {
        return this.assertionScheme;
    }

    public void setAssertionScheme(String assertionScheme)
    {
        this.assertionScheme = assertionScheme;
    }

    public Version[] getUpv()
    {
        return this.upv;
    }

    public void setUpv(Version[] upv)
    {
        this.upv = upv;
    }

    public String getDisplayContentType()
    {
        return this.displayContentType;
    }

    public void setDisplayContentType(String displayContentType)
    {
        this.displayContentType = displayContentType;
    }

    public Timestamp getCreateTimeStamp()
    {
        return this.createTimeStamp;
    }

    public void setCreateTimeStamp(Timestamp createTimeStamp)
    {
        this.createTimeStamp = createTimeStamp;
    }

    public Timestamp getUpdateTimeStamp()
    {
        return this.updateTimeStamp;
    }

    public void setUpdateTimeStamp(Timestamp updateTimeStamp)
    {
        this.updateTimeStamp = updateTimeStamp;
    }

    public List<Extension> getSupportedExtensions()
    {
        return this.supportedExtensions;
    }

    public void setSupportedExtensions(List<Extension> supportedExtensions)
    {
        this.supportedExtensions = supportedExtensions;
    }

    public boolean isKeyRestricted()
    {
        return this.isKeyRestricted;
    }

    public void setKeyRestricted(boolean isKeyRestricted)
    {
        this.isKeyRestricted = isKeyRestricted;
    }

    public boolean isFreshUserVerificationRequired()
    {
        return this.isFreshUserVerificationRequired;
    }

    public void setFreshUserVerificationRequired(boolean isFreshUserVerificationRequired)
    {
        this.isFreshUserVerificationRequired = isFreshUserVerificationRequired;
    }

    public List<ACKI> getAttestationCertKeyIds()
    {
        return this.attestationCertKeyIds;
    }

    public void setAttestationCertKeyIds(List<ACKI> attestationCertKeyIds)
    {
        this.attestationCertKeyIds = attestationCertKeyIds;
    }

    public String getAaguid()
    {
        return this.aaguid;
    }

    public void setAaguid(String aaguid)
    {
        this.aaguid = aaguid;
    }

    public boolean isExtensionSupported(String id)
    {
        if ((this.supportedExtensions == null) || (this.supportedExtensions.isEmpty())) {
            return false;
        }
        for (Extension ext : this.supportedExtensions) {
            if (ext.getId().equals(id)) {
                return true;
            }
        }
        return false;
    }

    public String getName()
    {
        this.name = this.aaguid.toString();
        return this.name;
    }

    public String toString()
    {
        return

                "AuthenticatorSpec [aaid=" + this.aaid + ", attestationCertKeyIds=" + this.attestationCertKeyIds + ", aaguid=" + this.aaguid + ", rootCertificates=" + this.rootCertificates + ", description=" + this.description + ", authenticatorVersion=" + this.authenticatorVersion + ", userVerificationMethods=" + this.userVerificationMethods + ", validAttachmentTypes=" + this.validAttachmentTypes + ", keyProtection=" + this.keyProtection + ", matcherProtection=" + this.matcherProtection + ", secureDisplay=" + this.secureDisplay + ", displayContentType=" + this.displayContentType + ", displayPNGCharacteristics=" + this.displayPNGCharacteristics + ", isSecondFactorOnly=" + this.isSecondFactorOnly + ", icon=" + this.icon + ", assertionScheme=" + this.assertionScheme + ", algorithm=" + this.algorithm + ", keyFormat=" + this.keyFormat + ", attestationTypes=" + this.attestationTypes + ", upv=" + Arrays.toString(this.upv) +  ", supportedExtensions=" + this.supportedExtensions + ", isKeyRestricted=" + this.isKeyRestricted + ", isFreshUserVerificationRequired=" + this.isFreshUserVerificationRequired + ", createTimeStamp=" + this.createTimeStamp + ", updateTimeStamp=" + this.updateTimeStamp + "]";
    }
}

